using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.DepartmentTree;

namespace TrainingManagement.api.Models.BusinessLogic.DepartmentTree
{
    public class DepartmentTreeDeleteOperation : BusinessOperation<int, bool>
    {
        readonly DepartmentTreeDeleteDataSource _departmentTreeDelete = new DepartmentTreeDeleteDataSource();

        public override bool Run(int input)
        {
            if (_departmentTreeDelete.Execute(input))
                return true;
            throw new Exception(string.Format("Failed to delete (treeId={0})", input));
        }
    }
}